package com.dameng.jianyouquan.mvp.view.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import com.dameng.jianyouquan.R;
import com.dameng.jianyouquan.api.Constant;
import com.dameng.jianyouquan.base.mvpBase.BaseMvpActivity;
import com.dameng.jianyouquan.interviewer.activity.MainInterViewerActivity;
import com.dameng.jianyouquan.jobhunter.activity.MainJobHunterActivity;
import com.dameng.jianyouquan.mvp.model.ChooseIdentityModel;
import com.dameng.jianyouquan.mvp.presenter.impl.ChooseIdentityPresenterImpl;
import com.dameng.jianyouquan.mvp.view.view.ChooseIdentityView;
import com.dameng.jianyouquan.utils.AppActivityManager;
import com.dameng.jianyouquan.utils.SpUtils;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class ChooseIdentityActivity extends BaseMvpActivity<ChooseIdentityPresenterImpl> implements ChooseIdentityView {

    @BindView(R.id.tv_job_hunter)
    TextView tvJobHunter;
    @BindView(R.id.tv_agent)
    TextView tvAgent;
    @BindView(R.id.tv_interviewer)
    TextView tvInterviewer;
    private ChooseIdentityPresenterImpl mPresenter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_choose_identity);
        ButterKnife.bind(this);

    }

    @Override
    protected void initData() {

    }

    @Override
    protected ChooseIdentityPresenterImpl createPresenter() {
        mPresenter = new ChooseIdentityPresenterImpl(this, new ChooseIdentityModel());
        return mPresenter;
    }


    @OnClick({R.id.tv_job_hunter, R.id.tv_agent, R.id.tv_interviewer})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.tv_job_hunter:
                mPresenter.ChooseIdentity(getApplicationContext(), "1");
                break;
            case R.id.tv_agent:
                mPresenter.ChooseIdentity(getApplicationContext(), "2");
                break;
            case R.id.tv_interviewer:
                mPresenter.ChooseIdentity(getApplicationContext(), "3");
                break;
        }
    }

    @Override
    public void chooseSuccess(String type) {
        switch (type) {
            case "1":
                showToast("进入求职者页面");
                SpUtils.setValueInt(getApplicationContext(), Constant.SP_ROLE_ID,1);
                SpUtils.setValueInt(getApplicationContext(), Constant.SP_STATUS,2);
                AppActivityManager.getInstance().killAllActivity();
                startActivity(new Intent(ChooseIdentityActivity.this, MainJobHunterActivity.class));
                break;
            case "2":
                showToast("进入代理商页面");
                SpUtils.setValueInt(getApplicationContext(), Constant.SP_ROLE_ID,2);
                SpUtils.setValueInt(getApplicationContext(), Constant.SP_STATUS,2);
                break;
            case "3":
                showToast("进入招聘者页面");
                SpUtils.setValueInt(getApplicationContext(), Constant.SP_ROLE_ID,3);
                SpUtils.setValueInt(getApplicationContext(), Constant.SP_STATUS,2);
                AppActivityManager.getInstance().killAllActivity();
                startActivity(new Intent(ChooseIdentityActivity.this, MainInterViewerActivity.class));
                break;
        }
    }

    @Override
    public void chooseFail(String msg) {
        showToast(msg);
    }


}
